<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登陆日志</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<style>
    .layui-form-pane .layui-form-label {
        width: auto !important;
    }

    .layui-table-cell {
        height: auto !important;
        white-space: normal;
    }

</style>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>日志列表</legend>
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        </fieldset>
    </div>
</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table', 'tree', 'util', 'laydate', 'layer', 'element'], function () {
        let form = layui.form,
            table = layui.table;


        table.render({
            elem: '#currentTableId',
            url: '/adminlog/getAdminlog',
            toolbar: '#toolbar',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            parseData:function(msg){
                console.log(msg);
                for (let i = 0; i < msg.data.length; i++) {
                    msg.data[i].createtime=renderTime(msg.data[i].createtime);
                }
                return msg;
            },
            cols: [
                [
                    {field: 'id', width: 80, title: '序号'},
                    {field: 'content', minWidth: 280, title: '内容'},
                    {field: 'createtime', width: 200, title: '时间'},
                ]
            ],
            id: 'recordReload',
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true
        });

        function renderTime(date) {
            return new Date(+new Date(new Date(date).toJSON()) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
        }

        // 监听搜索操作:部门
        form.on('submit(data-search-btn)', function (data) {
            let result = data.field;

            //执行搜索重载
            table.reload('recordReload', {
                url: 'XXXXXX'
                ,
                page: {
                    curr: 1
                }
                , where: {
                    id: result.id
                }
            }, 'data');

            return false;
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });


    });
</script>
</body>
</html>